function e(e, t, n) {
    return t in e ? Object.defineProperty(e, t, {
        value: n,
        enumerable: !0,
        configurable: !0,
        writable: !0
    }) : e[t] = n, e;
}

Object.defineProperty(exports, "__esModule", {
    value: !0
});

var t = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e;
} : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, n = function(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}(require("../component"));

exports.default = {
    setDefaults: function() {
        return {
            className: void 0,
            titleText: "安全键盘",
            cancelText: "取消",
            inputText: "输入数字密码",
            showCancel: !0,
            disorder: !1,
            callback: function(e) {}
        };
    },
    upsetNums: function() {
        var e = arguments.length > 0 && void 0 !== arguments[0] && arguments[0], t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ];
        if (e) for (var n = Math.floor, o = Math.random, i = t.length, u = void 0, a = void 0, r = void 0, s = n(i / 2) + 1; s--; ) (u = n(o() * i)) !== (a = n(o() * i)) && (r = t[u], 
        t[u] = t[a], t[a] = r);
        for (var l = [], d = 0; d < 4; d++) l.push(t.slice(3 * d, 3 * (d + 1)));
        return l;
    },
    show: function() {
        var o = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, i = Object.assign({
            animateCss: void 0,
            visible: !1,
            nums: this.upsetNums(o.disorder),
            keys: [ 1, 2, 3, 4, 5, 6 ],
            value: ""
        }, this.setDefaults(), o), u = new n.default({
            scope: "$wux.keyboard",
            data: i,
            methods: {
                hide: function() {
                    if (this.removed) return !1;
                    this.removed = !0, this.setHidden([ "wux-animate--slide-out-down", "wux-animate--fade-out" ]);
                },
                show: function() {
                    if (this.removed) return !1;
                    this.setVisible([ "wux-animate--slide-in-up", "wux-animate--fade-in" ]);
                },
                increase: function(e) {
                    var n = this, o = e.currentTarget.dataset, u = String(o.value), a = this.getComponentData(), r = a.value.length;
                    if (r >= 6) return !1;
                    this.updateValue(a.value + u, function() {
                        if (5 === r) {
                            var e = i.callback, o = n.updateValue, u = function() {
                                n.updateValue(), n.hide();
                            };
                            if (e && "function" == typeof e) {
                                var s = e.call(n, a.value);
                                "object" === (void 0 === s ? "undefined" : t(s)) ? s.closePromise ? s.closePromise.then(u, function() {
                                    return o();
                                }) : s.then(u, function() {
                                    return o();
                                }) : !1 !== s ? u() : o();
                            } else u();
                        }
                    });
                },
                decrease: function(e) {
                    var t = e.currentTarget.dataset, n = (String(t.value), this.getComponentData()), o = n.value.length;
                    if (0 === o) return !1;
                    this.updateValue(n.value.substr(0, o - 1));
                },
                updateValue: function() {
                    var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "", n = arguments[1];
                    this.setData(e({}, "$wux.keyboard.value", t), n);
                }
            }
        });
        return u.show(), u;
    }
};